package com.example.shoppingmall.service;

import com.example.shoppingmall.dao.StoreMapper;
import com.example.shoppingmall.pojo.Areas;
import com.example.shoppingmall.pojo.Cities;
import com.example.shoppingmall.pojo.Provinces;
import com.example.shoppingmall.pojo.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreService {

    @Autowired
    StoreMapper storeMapper;

    //查询门店+分页
    public List<Store> stoList(Integer pageNo, Integer pageNum){
        return storeMapper.stoList(pageNo, pageNum);
    }

    //查询总条数
    public int total(){
        return storeMapper.total();
    }

    //查询所有省市
    public List<Provinces> proList(){
        return storeMapper.proList();
    }

    //根据省市编码查询城市
    public List<Cities> citList(Integer provinceid){
        return storeMapper.citList(provinceid);
    }

    //根据城市编码查询市区
    public List<Areas> areList(Integer cityid){
        return storeMapper.areList(cityid);
    }

    //获取省的名字
    public Provinces getProName(Integer provinceid){
        return storeMapper.getProName(provinceid);
    }

    //获取城市的名字
    public Cities getCityName(Integer cityid){
        return storeMapper.getCityName(cityid);
    }

    //获取市区的名字
    public Areas getAreasName(Integer areaid){
        return storeMapper.getAreasName(areaid);
    }

    //新增门店
    public int stoAdd(Store store){
        return storeMapper.stoAdd(store);
    }

    //查询要修改的门店的信息
    public Store getSto(Integer id){
        return storeMapper.getSto(id);
    }

    //修改门店
    public int stoUpdate(Store store){
        return storeMapper.stoUpdate(store);
    }

    //删除门店
    public int stoDelete(Integer id){
        return storeMapper.stoDelete(id);
    }

}
